<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../jqgrid.jsp"></jsp:include>
</head>
<script type="text/javascript">
	var equipmentId = "";
	function queryAllEmployee() {
		var url = "queryAllEmployee.action";
		var types = "";
		$.ajax({
			type : "POST",
			url : url,
			dataType : "json",
			async : false,
			success : function(data) {
				$.each(data, function(i, item) {
					types += item["id"] + ":" + item["name"] + ";";
				});
			}
		});
		return types.substring(0, types.lastIndexOf(";"));
	} 
	$(document).ready(function() {
		jQuery("#workPlanlist").jqGrid({
			url : 'queryWorkPlan.action',
			autowidth : true,
			datatype : "json",
			colNames : [ 'id', '员工','员工', '工作日期', '班次', ],
			colModel : [ {
				name : 'id',
				index : 'id',
				width : 20,
				hidden:true,
				editable : false
			}, {
				name : 'eId',
				index : 'eId',
				width : 50,
				hidden:true,
				editable : true,
				edittype:"select",
				editrules:{
					required:true,
					edithidden:true
				},
				editoptions:{
					value:queryAllEmployee
				}
			},{
				name : 'eName',
				index : 'eName',
				align : "center",
				width : 20,
				editable : false,
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'workDay',
				index : 'workDay',
				width : 50,
				editable : true,
				formatter : "date",
				align : "center",
				editrules:{
					required:true,
					date:true
				},
				formatoptions : {
					"newformat" : "Y-m-d"
				},
				editoptions : {
					size : 10,
					maxlengh : 10,
					dataInit : function(element) {
						$(element).datepicker({
							dateFormat : 'yy-mm-dd'
						});
					}
				},
				searchoptions:{dataInit:datePick,sopt:['le','ge']}
			}, {
				name : 'workTime',
				index : 'workTime',
				width : 50,
				align : "center",
				editable : true,
				edittype : "select",
				editrules:{
					required:true
				},
				editoptions : {
					value : '早班:早班;中班:中班;夜班:夜班'
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			}],
			rowNum : 10,
			rowList : [ 10, 20, 30 ],
			pager : '#workPlangridPager',
			sortname : 'id',
			viewrecords : true,
			jsonReader : {
				repeatitems : false
			},
			sortorder : "desc",
			caption : "排班信息",
			editurl : "editWorkPlan.action",
		});
		jQuery("#workPlanlist").jqGrid('navGrid', '#workPlangridPager', {
			edit : true,
			add : true,
			del : true
		}, {}, {}, {}, {
			multipleSearch : true
		});
	});
	datePick = function(elem)
	{
	   jQuery(elem).datepicker();
	}
</script>
<body>
	<div align="center">
		<table id="workPlanlist"></table>
		<div id="workPlangridPager"></div>
	</div>
</body>
</html>